package com.cgbl.cg.adapter

import com.cgbl.cg.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.robot.base.model.CourseChaptarPeriodBean
import com.robot.base.util.LiveDataEventManager

class CourseProfileDirectoryListAdapter :
    BaseQuickAdapter<CourseChaptarPeriodBean, BaseViewHolder>(R.layout.app_item_course_diertory_list) {

    override fun convert(holder: BaseViewHolder, item: CourseChaptarPeriodBean) {
        if (item.free == "1") {
            holder.setText(R.id.tv_course_name, "${item.periodName} （免费观看）")
            holder.setText(R.id.tv_course_desc, "${item.periodDesc} （免费观看）")
        } else {
            holder.setText(R.id.tv_course_name, item.periodName)
            holder.setText(R.id.tv_course_desc, item.periodDesc)
        }
        holder.setVisible(R.id.tv_see, item.free == "1")
        holder.itemView.setOnClickListener {
            LiveDataEventManager.postPlayCourseEvent(item.resourcePath)
        }
    }
}